﻿//-------------------------------------------------------------------
//	Copyright (c) 2010-2014  Zhirnov Andrey
//	This file is part of the "UX Standard Lib" project.
//	See copyright notice in "UX_Logger.h".
//-------------------------------------------------------------------

#ifndef _UXS_LOGGER_INTERFACE_H
#define _UXS_LOGGER_INTERFACE_H

#pragma once

#include "../../stl_core/ux_stl_core.h"
#include "../../stl_ext/OS/OSPlatform.h"


namespace UX_STL
{
	using namespace UXTypes;


	//
	// Log Message Type
	//

	namespace e_log_msg
	{
		UX_ENUM_BIT_OPERATIONS( type );
	}
	UX_ENUM_META_OBJECT( e_log_msg::type );


namespace UXLogger
{
	using namespace UXTypes;
	using namespace UXTypesExt;


	//
	// Log Output Type
	//

	namespace e_log_output
	{
		enum	type :	uint8
		{
			UNKNOWN		= 0,
			LOG_FILE,
			MESSAGE,
			CONSOLE,
			IDE_CONSOLE,
		};

		enum	bits :	uint32
		{
			UNKNOWN_BIT		= 0,
			LOG_FILE_BIT	= 1 << LOG_FILE,
			MESSAGE_BIT		= 1 << MESSAGE,
			CONSOLE_BIT		= 1 << CONSOLE,
			IDE_CONSOLE_BIT	= 1 << IDE_CONSOLE,
		};

		UX_ENUM_BIT_OPERATIONS( bits );
	}
	//UX_ENUM_META_OBJECT( e_log_output::type );
	//UX_ENUM_META_OBJECT( e_log_output::bits );



	//
	// Log Output interface
	//

	class ILogOutput
	{
	public:
		virtual void Write(const char *pMsg, e_log_msg::type eType, const char *pSrcFile, uint uLine) = 0;
		virtual e_log_output::bits	GetTypeBits() const = 0;
		virtual void NewLine() = 0;
		virtual void Free() = 0;
	};



	//
	// Logger interface
	//

	class ILogger
	{
	public:
		typedef function< void >	CallbackProc_t;
		
		virtual void SetCallback(const CallbackProc_t &sOnFatalError) = 0;

		virtual void Attach(ILogOutput *pOutput) = 0;
		virtual void Detach(ILogOutput *pOutput) = 0;
		virtual void FreeAll() = 0;

		virtual void NewLine() = 0;
		virtual void Write(const char *pMsg, e_log_msg::type eType) = 0;
		virtual void WriteExt(const char *pMsg, e_log_msg::type eType, const char *pSrcFile, uint uLine) = 0;
		
		virtual void Write(uni_c_string sMsg, e_log_msg::type eType) = 0;
		virtual void WriteExt(uni_c_string sMsg, e_log_msg::type eType, const char *pSrcFile, uint uLine) = 0;

		virtual void SetFlagFilter(e_log_msg::type eFlag) = 0;
		virtual void SetWarningFilter(uint uLevel) = 0;
	};

//-------------------------------------------------------------------

}	// UXLogger
}	// UX_STL

#endif	// _UXS_LOGGER_INTERFACE_H